#include "HW1_UI.h"
#include "Hw1_Server.h"
#include "MUA_utils.h"
#include <stdio.h>
#include <string.h>



void main(int argc, char *argv[])
{
	int i,j,num_of_interfaces;
	
	//define UIS
	Interface UI = {"UIInitialization", Initilize_UI, Close_UI, F};
	Interface Server = {"ServerInitialization", Initilize_Server, Close_Server, F};
	//why doesnt it work?!
	Interface interfaces[NUM_OF_IFS];
	interfaces[0] = UI;
	interfaces[1] = Server;

	//compute number of interfaces
	num_of_interfaces = sizeof(interfaces)/sizeof(Interface);
	
	//initialize all interfaces with matching strings 
	for(i=1; i<argc; i++)
	{
		for (j=0; j<num_of_interfaces; j++)
		{	
			if (strncmp(argv[i], interfaces[j].setup_string, strlen(argv[i])) == 0)
			{
				(*interfaces[j].init_func) (argv[i]);
				interfaces[j].initialized = T;
			}
	
		}
	}

	//run in loop
	testList();



	//close all interfaces that were initialized
	for (j=0; j<num_of_interfaces; j++)
	{	
		{
			if (interfaces[j].initialized == T)
			{
				(*interfaces[j].close_func) ();
			}
		}
	
	}

	scanf("%d", &i);
}

//TODO: UNIT TEST List.c, give notice for bad input?
